package com.globallogic.training.javase.money;

import java.util.Hashtable;

public class Bank {

	private Hashtable rates = new Hashtable();
	
	Expression reduce(Expression source, String to) {
		return source.reduce(this, to);
	}
	
	void addRate(String from, String to, int rate) {
		rates.put(new Pair(from, to), new Integer(rate));
	}
	
	int rate(String from, String to) {
		if (from.equals(to)) {
			return 1;
		}
		Integer integer = (Integer) rates.get(new Pair(from, to));
		return integer.intValue();
	}
}
